package com.hdu.kdk_feign.paramHandler;

import com.hdu.kdk_feign.annotation.RequestBody;
import com.hdu.kdk_feign.utils.Assert;


public class RequestBodyParamHandler implements ParamHandler {


    @Override
    public boolean support(Param param) {
        return param.getParamAnnotation() != null
                &&
                param.getParamAnnotation().annotationType().isAssignableFrom(RequestBody.class);
    }

    @Override
    public void handle(TotalRequestParamInfo totalRequestParamInfo, Param param) {
        Assert.isTrue(
                totalRequestParamInfo.getRequestBody() != null,
                "@RequestBody can be only set one time"
        );
        totalRequestParamInfo.setRequestBody(param.getParamValue());
    }
}
